package org.colcon.web.client.ui;

import org.colcon.web.client.Collective_Congress;
import org.colcon.web.client.ui.link.LoginLink;
import org.colcon.web.client.ui.link.LogoutLink;
import org.colcon.web.client.ui.link.RegisterLink;
import org.colcon.web.client.ui.panel.LogoPanel;

import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class HeaderPanel extends ColConPanel 
{
	public HeaderPanel(Collective_Congress client)
	{
		super(client);
		
		HorizontalPanel headerPanel = new HorizontalPanel();
		
		headerPanel.setStyleName("header");
		
		headerPanel.add(new LogoPanel(client));
		headerPanel.add(new LinkPanel(client, "header-item", "news"));
		headerPanel.add(new LinkPanel(client, "header-item", "groups"));
		headerPanel.add(new LinkPanel(client, "header-item", "users"));
		
		VerticalPanel userPanel = new VerticalPanel();
		
		if(getClient().loggedIn())
		{
			userPanel.add(new LinkPanel(client, "user-item", client.getUser().getPath()));
			userPanel.add(new LogoutLink(client));
		}
		else
		{
			userPanel.add(new RegisterLink(client));
			userPanel.add(new LoginLink(client));
		}
		
		headerPanel.add(userPanel);
		
		add(headerPanel);
	}
}
